<?php
require_once('lib/dbclass.php');
$db = new MySQL();

	


// insert ke Database tabel agenda
if(isset($_POST['tambah'])){
	//upload file
	// $location_file = $_FILES['gambar']['tmp_name'];
	// $name_file = $_FILES['gambar']['name'];

	// move_uploaded_file($location_file,"images/berita/$name_file");
	//end upload
	
	$id_agenda = $_POST['id_agenda'];
	$tema = $_POST['tema'];
	$isi = $_POST['isi'];
	$tempat = $_POST['tempat'];
	
	
if($id_agenda=='' OR $tema=='' OR $isi=='' OR $tempat==''){
	echo '<script>';
	echo "alert('Error: data yang diisikan tidak boleh kosong');";
	echo "window.location='index.php?q=11'";
	echo '</script>';
}else{
	
	if (! $db->Query("insert into agenda(id_agenda,tema,isi,tempat) 
		values('$id_agenda','$tema','$isi','$tempat')")) $db->Kill(); 
		
	echo '<script>';
	echo "alert('Success: Anda berhasil menambah agenda baru');";
	echo "window.location='index.php?q=1'";
	echo '</script>';
}
}
?>



<form class="form-horizontal" role="form" action="" method='post' enctype="multipart/form-data">
			
			<div class="form-group">
				
				<label for="kode" class="col-sm-2 control-label"> Kode   : </label>
				<div class="col-sm-10">
				<input class="form-control" type="text" name="id_agenda" id="id_agenda" value="<?php echo $_SESSION['session_usr'];?>" placeholder="Kode Agenda">
				
			</div>
			</div>

			<div class="form-group">
				
				<label for="tema" class="col-sm-2 control-label">Tema      :</label>
				<div class="col-sm-10">
				<input class="form-control" type="text" name="tema" placeholder="Tema">
				
			</div>

			</div>
				<div class="form-group">
					
				<label for="body" class="col-sm-2 control-label">Isi Agenda :</label>
				<div class="col-sm-10">
				<textarea class="form-control editor" name="isi" rows="12" placeholder="Page Body"></textarea>
				</div>
			</div>

			<div class="form-group">
				
				<label for="tempat" class="col-sm-2 control-label">Tempat      :</label>
				<div class="col-sm-10">
				<input class="form-control" type="text" name="tempat" placeholder="Tempat">
				
			</div>			
			
			<div class="form-group">
		    <div class="col-sm-offset-2 col-sm-10">
		      <div class="checkbox">
		        <label>
		        	<input type='radio' value='Publik' name='tipe' />
					Publik
					  <input type='radio' value='Privat' name='tipe' />
					Privat </td>
		        </label>
		    </div>
		    </div>
		   	</div>
			
			
			<div class="form-group">
					
				<label for="body" class="col-sm-2 control-label"></label>
				<div class="col-sm-10">
					&nbsp;
				</div>
			</div>
			
			<div class="form-group">
   			<div class="col-sm-offset-2 col-sm-10">
			<button type="submit" class="btn btn-success">Save</button>
			<input type="hidden" name="tambah" value="Simpan">
			</div>
			</div>
			
		</form>
	
